package file;

public class BookSystem {
    public static  void main(String[] args) {
        //1.初始化图书数据
        String[] bookIds = {"B001","B002","B003","B004","B005"};
        String[] bookNames = {"Java编程基础","数据结构与算法","Python入门","数据库原理","计算机网络"};
        boolean[] isBorrowed = {true,false,true,false,false}; //true：已借出，false：未借出

        //2.输出所有未借出的图书
        System.out.println("当前可借阅的图书: ");
        int availableCount = 0;
        for (int i = 0; i < bookIds.length; i++) {
            if (!isBorrowed[i]) { // 未借出
                System.out.println(bookIds[i] + ": " + bookNames[i]);
                availableCount++;
            }
        }
        System.out.println("可借阅图书总数: " + availableCount);

        // 3. 处理图书归还（B001归还）
        String returnBookId = "B001";
        for (int i = 0; i < bookIds.length; i++) {
            if (bookIds[i].equals(returnBookId)) {
                isBorrowed[i] = false;
                System.out.println("\n" + returnBookId + " 已归还");
                break;
            }
        }
                // 4. 再次统计可借阅图书数量
                availableCount = 0;
                for (boolean borrowed : isBorrowed) {
                    if (!borrowed) availableCount++;
                }
                System.out.println("归还后可借阅图书总数: " + availableCount);
    }
}
